package writtenTest;

public class Text3 {
    public static void main(String[] args) {
        /*
         * 超市做促销活动，草莓限时打 8 折。
         * 现在顾客 C 在超市购买了若干斤苹果、 草莓和芒果，需计算一共需要多少钱？
         * 请编写函数，对于 C 购买的水果斤数 (水果斤数为大于等于 0 的整数)，计算并返回所购买商品的总价。
         */
        int weight = 15;
        int oneApplePrice = 10;
        int oneStrawberryPrice = 12;
        int oneMongo = 20;
        int appleWeight = 0;
        int strawberryWeight = 0;
        int mongoWeight = 0;

        if(weight % 3 == 0){
            int tempWeight = weight / 3;
            appleWeight = tempWeight;
            strawberryWeight = tempWeight;
            mongoWeight = tempWeight;
        }else{
            int tempWeight = (weight - 1) / 3;
            appleWeight = tempWeight + 1;
            strawberryWeight = tempWeight;
            mongoWeight = tempWeight;
        }
        double applePrice = (oneApplePrice * appleWeight)*0.8;
        int strawberryPrice = oneStrawberryPrice * strawberryWeight;
        int mongsPrice  = oneMongo * mongoWeight;
        double sumPrice = applePrice + strawberryPrice + mongsPrice;
        System.out.println("苹果重量为：" + appleWeight + "；苹果价格为：" + applePrice);
        System.out.println("草莓重量为：" + strawberryWeight + "；草莓打折后价格为：" + strawberryPrice);
        System.out.println("芒果重量为：" + mongoWeight + ";芒果价格为：" + mongsPrice);
        System.out.println("总重量为：" + weight + "；总价格为：" + sumPrice);

    }
}
